package com.ruoyi.tester.service.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.tester.mapper.TesterTaskInterfaceRelationMapper;
import com.ruoyi.tester.domain.TesterTaskInterfaceRelation;
import com.ruoyi.tester.service.ITesterTaskInterfaceRelationService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.util.CollectionUtils;

/**
 * 任务-接口关联关系Service业务层处理
 *
 * @author SJ
 * @date 2022-04-25
 */
@Service
public class TesterTaskInterfaceRelationServiceImpl implements ITesterTaskInterfaceRelationService
{
    @Autowired
    private TesterTaskInterfaceRelationMapper testerTaskInterfaceRelationMapper;

    /**
     * 查询任务-接口关联关系
     *
     * @param relationId 任务-接口关联关系主键
     * @return 任务-接口关联关系
     */
    @Override
    public TesterTaskInterfaceRelation selectTesterTaskInterfaceRelationByRelationId(Long relationId)
    {
        return testerTaskInterfaceRelationMapper.selectTesterTaskInterfaceRelationByRelationId(relationId);
    }

    /**
     * 查询任务-接口关联关系列表
     *
     * @param testerTaskInterfaceRelation 任务-接口关联关系
     * @return 任务-接口关联关系
     */
    @Override
    public List<TesterTaskInterfaceRelation> selectTesterTaskInterfaceRelationList(TesterTaskInterfaceRelation testerTaskInterfaceRelation)
    {
        return testerTaskInterfaceRelationMapper.selectTesterTaskInterfaceRelationList(testerTaskInterfaceRelation);
    }

    @Override
    public List<TesterTaskInterfaceRelation> selectInRelationIds(Collection<Long> relationIds){
        if (CollectionUtils.isEmpty(relationIds)) {
            return new ArrayList<>();
        }
        return testerTaskInterfaceRelationMapper.selectInRelationIds(relationIds);
    }

    /**
     * 新增任务-接口关联关系
     *
     * @param testerTaskInterfaceRelation 任务-接口关联关系
     * @return 结果
     */
    @Override
    public int insertTesterTaskInterfaceRelation(TesterTaskInterfaceRelation testerTaskInterfaceRelation)
    {
        testerTaskInterfaceRelation.setCreateTime(DateUtils.getNowDate());
        return testerTaskInterfaceRelationMapper.insertTesterTaskInterfaceRelation(testerTaskInterfaceRelation);
    }

    /**
     * 修改任务-接口关联关系
     *
     * @param testerTaskInterfaceRelation 任务-接口关联关系
     * @return 结果
     */
    @Override
    public int updateTesterTaskInterfaceRelation(TesterTaskInterfaceRelation testerTaskInterfaceRelation)
    {
        testerTaskInterfaceRelation.setUpdateTime(DateUtils.getNowDate());
        return testerTaskInterfaceRelationMapper.updateTesterTaskInterfaceRelation(testerTaskInterfaceRelation);
    }

    /**
     * 批量删除任务-接口关联关系
     *
     * @param relationIds 需要删除的任务-接口关联关系主键
     * @return 结果
     */
    @Override
    public int deleteTesterTaskInterfaceRelationByRelationIds(String relationIds)
    {
        return testerTaskInterfaceRelationMapper.deleteTesterTaskInterfaceRelationByRelationIds(Convert.toStrArray(relationIds));
    }

    /**
     * 删除任务-接口关联关系信息
     *
     * @param relationId 任务-接口关联关系主键
     * @return 结果
     */
    @Override
    public int deleteTesterTaskInterfaceRelationByRelationId(Long relationId)
    {
        return testerTaskInterfaceRelationMapper.deleteTesterTaskInterfaceRelationByRelationId(relationId);
    }
}
